package cz.proks.schoolpupilbook.gae.restlet.resource;

import cz.proks.schoolpupilbook.gae.dao.CourseDAO;
import cz.proks.schoolpupilbook.shared.domain.Course;
import cz.proks.schoolpupilbook.shared.restlet.RestMapping;
import cz.proks.schoolpupilbook.shared.util.Tester;

public class CourseServerResource extends BaseServerResource implements CourseResource {
	CourseDAO dao = new CourseDAO();
	
	@Override
	public Course retrieve() {
		String courseId = (String) getRequestAttributes().get(RestMapping.PARAMETER_COURSE_ID);		
		
		if (Tester.isEmpty(courseId))
			return null;
		
		Course course = dao.find(courseId);		
		return course;
	}

	@Override	
	public void store(Course obj) {						
		dao.save(obj);		
	}
}
